<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp"%>
<title>常用字符串处理 - 切割、拼接、检索、替换</title>
<style type="text/css">
</style>
<script type="text/javascript">
 $.extend($.fn.validatebox.defaults.rules, {
	//非空切只能是整数的验证
    passfir: {
        validator: function (value,param) {debugger
        	if(value != "" && value != null){
        		if(!/^\+?[0-9][0-9]*$/.test(value)){
            		$.fn.validatebox.defaults.rules.passfir.message= "只能输入数字!";
            		return false;
            	}else{
            		var len = $("#str").val().length;
            		if(len > value){
            			return true;
            		}
            		$.fn.validatebox.defaults.rules.passfir.message= "数字长度不能超过待截取字符串的字符长度!";
            		return false;
            	}
        	}else{
        		$.fn.validatebox.defaults.rules.passfir.message= "请输入字符串截取范围!";
        	}
        	return true;
        },
    },
    passsec: {
        validator: function (value,param) {debugger
        	if(value != "" && value != null){
        		if(!/^\+?[0-9][0-9]*$/.test(value)){
            		$.fn.validatebox.defaults.rules.passsec.message= "只能输入数字";
            		return false;
            	}else{
            		var len = $("#str").val().length;
            		if(len > value){
            			if($("#begin").val() > value-1){
            				$.fn.validatebox.defaults.rules.passsec.message= "末端坐标不能大于初始坐标";
                    		return false;
            			}
            			return true;
            		}
            		$.fn.validatebox.defaults.rules.passsec.message= "数字长度不能超过待截取字符串的字符长度!";
            		return false;
            	}
        		return true;
        	}
        	return true;
        },
    },
   /*  nottnull: {
        validator: function (value,param) {debugger
        	if(value == "" || value == null){
        		$.fn.validatebox.defaults.rules.nottnull.message= "不能为空";
        		return false;
        	}else{
        		return true;
        	}
        },
    }, */
}); 
	$(function(){
		$('#fm1').form({
			url:'${ctx}/cultivate/split',
			onSubmit: function(){
				return $(this).form('validate');
			},
			success:function(data){debugger
				$("#result1").textbox("setValue", data);
			}
		});
		
		$('#fm2').form({
			url:'${ctx}/cultivate/substring',
			onSubmit: function(){
				return $(this).form('validate');
			},
			success:function(data){debugger
				$("#result2").textbox("setValue", data);
			}
		});
		
		$('#fm3').form({
			url:'${ctx}/cultivate/concat',
			onSubmit: function(){
				return $(this).form('validate');
			},
			success:function(data){debugger
				$("#result3").textbox("setValue", data);
			}
		});
		$('#fm4').form({
			url:'${ctx}/cultivate/indexOf',
			onSubmit: function(){
				return $(this).form('validate');
			},
			success:function(data){debugger
				$("#result4").textbox("setValue", data);
			}
		});
		$('#fm5').form({
			url:'${ctx}/cultivate/endsWith',
			onSubmit: function(){
				return $(this).form('validate');
			},
			success:function(data){debugger
				$("#result5").textbox("setValue", data);
			}
		});
		$('#fm6').form({
			url:'${ctx}/cultivate/replaceAll',
			onSubmit: function(){
				return $(this).form('validate');
			},
			success:function(data){debugger
				$("#result6").textbox("setValue", data);
			}
		});
		$('#fm7').form({
			url:'${ctx}/cultivate/toLowerOrUpperCase',
			onSubmit: function(){
				return $(this).form('validate');
			},
			success:function(data){debugger
				$("#result7").textbox("setValue", data);
			}
		});
	});
	function saved1(){debugger
		$('#fm1').submit();
	};
	function saved2(){debugger
		$('#fm2').submit();
	};
	function saved3(){debugger
		$('#fm3').submit();
	};
	function saved4(){debugger
		$('#fm4').submit();
	};
	function saved5(){debugger
		$('#fm5').submit();
	};
	function saved6(){debugger
		$('#fm6').submit();
	};
	function saved7(){debugger
		$('#fm7').submit();
	};
</script>
</head>
<body>
	<div class="str">
		<h3>常用字符串处理 - 切割、拼接、检索、替换</h3>
		<!-- ----------------------------------------- -->
		<div>
			<form id="fm1" method="post" class="form-horizontal" role="form">
				<label style="margin-left:15px;">split待截取字符串：</label>
						<input class="easyui-textbox" style="width:125px" name="str1" id="str1" required="required"/>
				<label style="margin-left:15px;">正则表达式(为空的话代表以" "切割)：</label>
						<input class="easyui-textbox" style="width:125px" name="str2" id="str2"/>
			</form>
			<a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search" onclick="javascript:saved1()">查询</a>
			<label style="margin-left:15px;">截取字符串结果：</label><input class="easyui-textbox" style="width:125px" name="result1" id="result1" readonly="readonly"/>
		</div>
		<hr>
		<!-- ----------------------------------------- -->
		<div>
			<form id="fm2" method="post" class="form-horizontal" role="form">
				<label style="margin-left:15px;">substring待截取字符串：</label><input class="easyui-textbox" style="width:125px" name="str" id="str" required="required"/>
				<label style="margin-left:15px;">切割范围(下标从0开始)：</label>
						<input class="easyui-textbox" style="width:125px" name="begin" id="begin" validType="passfir[0,100]"/>~
						<input class="easyui-textbox" style="width:125px" name="end" id="end" validType="passsec[0,100]"/>
			</form>
			<a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search" onclick="javascript:saved2()">查询</a>
			<label style="margin-left:15px;">截取字符串结果：</label><input class="easyui-textbox" style="width:125px" name="result2" id="result2" readonly="readonly"/>
		</div>
		<hr>
		<!-- ----------------------------------------- -->
		<div>
			<form id="fm3" method="post" class="form-horizontal" role="form">
				<label style="margin-left:15px;">concat待拼接字符串1：</label>
						<input class="easyui-textbox" style="width:125px" name="str1" id="str1" required="required"/>
				<label style="margin-left:15px;">concat待拼接字符串2：</label>
						<input class="easyui-textbox" style="width:125px" name="str2" id="str2" required="required"/>
			</form>
			<a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search" onclick="javascript:saved3()">查询</a>
			<label style="margin-left:15px;">拼接字符串结果：</label><input class="easyui-textbox" style="width:125px" name="result3" id="result3" readonly="readonly"/>
		</div>
		<hr>
		<!-- ----------------------------------------- -->
		<div>
			<form id="fm4" method="post" class="form-horizontal" role="form">
				<label style="margin-left:15px;">indexOf查找指定字符串母串：</label>
						<input class="easyui-textbox" style="width:125px" name="str4" id="str4" required="required"/>
				<label style="margin-left:15px;">待查找的子串：</label>
						<input class="easyui-textbox" style="width:125px" name="str5" id="str5" required="required"/>
						
			</form>
			<a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search" onclick="javascript:saved4()">查询</a>
			<label style="margin-left:15px;">待查找的子串的位置：</label><input class="easyui-textbox" style="width:125px" name="result4" id="result4" readonly="readonly"/>
		</div>
		<hr>
		<!-- ----------------------------------------- -->
		<div>
			<form id="fm5" method="post" class="form-horizontal" role="form">
				<label style="margin-left:15px;">endsWith是否已指定字符串结尾：</label>
						<input class="easyui-textbox" style="width:125px" name="str6" id="str6" required="required"/>
				<label style="margin-left:15px;">结尾的子串：</label>
						<input class="easyui-textbox" style="width:125px" name="str7" id="str7" required="required"/>
			</form>
			<a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search" onclick="javascript:saved5()">查询</a>
			<label style="margin-left:15px;">是否已指定字串结尾：</label>
				<input class="easyui-textbox" style="width:125px" name="result5" id="result5" readonly="readonly"/>
		</div>
		<hr>
		<!-- ----------------------------------------- -->
		<div>
			<form id="fm6" method="post" class="form-horizontal" role="form">
				<label style="margin-left:15px;">replaceAll待替换的母串：</label>
						<input class="easyui-textbox" style="width:125px" name="str8" id="str8" required="required"/>
				<label style="margin-left:15px;">被替换的子串：</label>
						<input class="easyui-textbox" style="width:125px" name="str9" id="str9" required="required"/>
				<label style="margin-left:15px;">替换的子串：</label>
						<input class="easyui-textbox" style="width:125px" name="str10" id="str10"/>
			</form>
			<a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search" onclick="javascript:saved6()">替换</a>
			<label style="margin-left:15px;">是否已指定字串结尾：</label>
				<input class="easyui-textbox" style="width:125px" name="result6" id="result6" readonly="readonly"/>
		</div>
		<hr>
		<!-- ----------------------------------------- -->
		<div>
			<form id="fm7" method="post" class="form-horizontal" role="form">
				<label style="margin-left:15px;">待转换大小写的字符串：</label>
						<input class="easyui-textbox" style="width:125px" name="str11" id="str11" required="required"/>
				<label style="margin-left:15px;">转换策略：</label>
				<select id="flag" name="flag" class="easyui-combobox" panelHeight="auto">
						<option value="toUpper">全部转为大写</option>
						<option value="toLower">全部转为小写</option>
				</select>
			</form>
			<a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search" onclick="javascript:saved7()">转换</a>
			<label style="margin-left:15px;">转换结果：</label>
				<input class="easyui-textbox" style="width:125px" name="result7" id="result7" readonly="readonly"/>
		</div>
	</div>
</body>
</html>